home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / octa209s.zip / octave-2.09 / libcruft / lapack / dorghr.f < prev    next >
Text File  |  1996-07-19  |  4KB  |  145 lines

  1.       SUBROUTINE DORGHR( N, ILO, IHI, A, LDA, TAU, WORK, LWORK, INFO )
  2. *
  3. *  -- LAPACK routine (version 2.0) --
  4. *     Univ. of Tennessee, Univ. of California Berkeley, NAG Ltd.,
  5. *     Courant Institute, Argonne National Lab, and Rice University
  6. *     September 30, 1994
  7. *
  8. *     .. Scalar Arguments ..
  9.       INTEGER            IHI, ILO, INFO, LDA, LWORK, N
  10. *     ..
  11. *     .. Array Arguments ..
  12.       DOUBLE PRECISION   A( LDA, * ), TAU( * ), WORK( LWORK )
  13. *     ..
  14. *
  15. *  Purpose
  16. *  =======
  17. *
  18. *  DORGHR generates a real orthogonal matrix Q which is defined as the
  19. *  product of IHI-ILO elementary reflectors of order N, as returned by
  20. *  DGEHRD:
  21. *
  22. *  Q = H(ilo) H(ilo+1) . . . H(ihi-1).
  23. *
  24. *  Arguments
  25. *  =========
  26. *
  27. *  N       (input) INTEGER
  28. *          The order of the matrix Q. N >= 0.
  29. *
  30. *  ILO     (input) INTEGER
  31. *  IHI     (input) INTEGER
  32. *          ILO and IHI must have the same values as in the previous call
  33. *          of DGEHRD. Q is equal to the unit matrix except in the
  34. *          submatrix Q(ilo+1:ihi,ilo+1:ihi).
  35. *          1 <= ILO <= IHI <= N, if N > 0; ILO=1 and IHI=0, if N=0.
  36. *
  37. *  A       (input/output) DOUBLE PRECISION array, dimension (LDA,N)
  38. *          On entry, the vectors which define the elementary reflectors,
  39. *          as returned by DGEHRD.
  40. *          On exit, the N-by-N orthogonal matrix Q.
  41. *
  42. *  LDA     (input) INTEGER
  43. *          The leading dimension of the array A. LDA >= max(1,N).
  44. *
  45. *  TAU     (input) DOUBLE PRECISION array, dimension (N-1)
  46. *          TAU(i) must contain the scalar factor of the elementary
  47. *          reflector H(i), as returned by DGEHRD.
  48. *
  49. *  WORK    (workspace/output) DOUBLE PRECISION array, dimension (LWORK)
  50. *          On exit, if INFO = 0, WORK(1) returns the optimal LWORK.
  51. *
  52. *  LWORK   (input) INTEGER
  53. *          The dimension of the array WORK. LWORK >= IHI-ILO.
  54. *          For optimum performance LWORK >= (IHI-ILO)*NB, where NB is
  55. *          the optimal blocksize.
  56. *
  57. *  INFO    (output) INTEGER
  58. *          = 0:  successful exit
  59. *          < 0:  if INFO = -i, the i-th argument had an illegal value
  60. *
  61. *  =====================================================================
  62. *
  63. *     .. Parameters ..
  64.       DOUBLE PRECISION   ZERO, ONE
  65.       PARAMETER          ( ZERO = 0.0D+0, ONE = 1.0D+0 )
  66. *     ..
  67. *     .. Local Scalars ..
  68.       INTEGER            I, IINFO, J, NH
  69. *     ..
  70. *     .. External Subroutines ..
  71.       EXTERNAL           DORGQR, XERBLA
  72. *     ..
  73. *     .. Intrinsic Functions ..
  74.       INTRINSIC          MAX, MIN
  75. *     ..
  76. *     .. Executable Statements ..
  77. *
  78. *     Test the input arguments
  79. *
  80.       INFO = 0
  81.       IF( N.LT.0 ) THEN
  82.          INFO = -1
  83.       ELSE IF( ILO.LT.1 .OR. ILO.GT.MAX( 1, N ) ) THEN
  84.          INFO = -2
  85.       ELSE IF( IHI.LT.MIN( ILO, N ) .OR. IHI.GT.N ) THEN
  86.          INFO = -3
  87.       ELSE IF( LDA.LT.MAX( 1, N ) ) THEN
  88.          INFO = -5
  89.       ELSE IF( LWORK.LT.MAX( 1, IHI-ILO ) ) THEN
  90.          INFO = -8
  91.       END IF
  92.       IF( INFO.NE.0 ) THEN
  93.          CALL XERBLA( 'DORGHR', -INFO )
  94.          RETURN
  95.       END IF
  96. *
  97. *     Quick return if possible
  98. *
  99.       IF( N.EQ.0 ) THEN
  100.          WORK( 1 ) = 1
  101.          RETURN
  102.       END IF
  103. *
  104. *     Shift the vectors which define the elementary reflectors one
  105. *     column to the right, and set the first ilo and the last n-ihi
  106. *     rows and columns to those of the unit matrix
  107. *
  108.       DO 40 J = IHI, ILO + 1, -1
  109.          DO 10 I = 1, J - 1
  110.             A( I, J ) = ZERO
  111.    10    CONTINUE
  112.          DO 20 I = J + 1, IHI
  113.             A( I, J ) = A( I, J-1 )
  114.    20    CONTINUE
  115.          DO 30 I = IHI + 1, N
  116.             A( I, J ) = ZERO
  117.    30    CONTINUE
  118.    40 CONTINUE
  119.       DO 60 J = 1, ILO
  120.          DO 50 I = 1, N
  121.             A( I, J ) = ZERO
  122.    50    CONTINUE
  123.          A( J, J ) = ONE
  124.    60 CONTINUE
  125.       DO 80 J = IHI + 1, N
  126.          DO 70 I = 1, N
  127.             A( I, J ) = ZERO
  128.    70    CONTINUE
  129.          A( J, J ) = ONE
  130.    80 CONTINUE
  131. *
  132.       NH = IHI - ILO
  133.       IF( NH.GT.0 ) THEN
  134. *
  135. *        Generate Q(ilo+1:ihi,ilo+1:ihi)
  136. *
  137.          CALL DORGQR( NH, NH, NH, A( ILO+1, ILO+1 ), LDA, TAU( ILO ),
  138.      $                WORK, LWORK, IINFO )
  139.       END IF
  140.       RETURN
  141. *
  142. *     End of DORGHR
  143. *
  144.       END
  145.